//package com.zmn.plat.admin.controller.category;
//
//import java.util.List;
//import java.util.Objects;
//
//import javax.annotation.Resource;
//
//import com.zmn.common.dto2.ResponseDTO;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.CollectionUtils;
//
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.constant.StatusConsts;
//import com.zmn.common.dto.ResultDTO;
//import com.zmn.plat.admin.controller.PlatBaseController;
//import com.zmn.plat.business.interfaces.category.BaseCategoryAttributeBService;
//import com.zmn.plat.business.interfaces.category.BaseCategoryBService;
//import com.zmn.plat.es.EsBaseCategoryService;
//import com.zmn.plat.model.entity.category.BaseCategory;
//import com.zmn.plat.model.entity.category.BaseCategoryQuery;
//import com.zmn.plat.model.entity.product.ServProduct;
//import com.zmn.plat.model.entity.product.ServProductQuery;
//import com.zmn.plat.services.interfaces.category.BaseCategoryAttributeEnumService;
//import com.zmn.plat.services.interfaces.category.BaseCategoryAttributeService;
//import com.zmn.plat.services.interfaces.category.BaseCategoryService;
//import com.zmn.plat.services.interfaces.channel.ChannelService;
//import com.zmn.plat.services.interfaces.product.ServProductService;
//
///**
// * @author duanzuocai
// * @version v1.0
// * @since 2018/10/20 9:15
// * @类说明：分类基础控制器
// */
//public class CategoryBaseController extends PlatBaseController {
//    protected Logger logger = LoggerFactory.getLogger(this.getClass());
//
//    @Resource
//    protected BaseCategoryService baseCategoryService;
//    @Resource
//    protected ServProductService servProductService;
//    @Resource
//    protected BaseCategoryBService baseCategoryBService;
//    @Resource
//    protected BaseCategoryAttributeBService baseCategoryAttributeBService;
//    @Resource
//    protected BaseCategoryAttributeService baseCategoryAttributeService;
//    @Resource
//    protected BaseCategoryAttributeEnumService baseCategoryAttributeEnumService;
//    @Autowired
//    protected EsBaseCategoryService esBaseCategoryService;
//    @Autowired
//    protected ChannelService channelService;
//
//    public ResponseDTO checkCategoryStatus(List<Integer> arrayIds, Integer showType, Integer status) {
//        if (!CollectionUtils.isEmpty(arrayIds)) {
//            Integer id = arrayIds.get(0);
//            BaseCategory baseCategory = baseCategoryService.findByKey(id);
//            if (Objects.equals(GlobalConsts.NO, status)) {
//                if (baseCategory.getLevel() == GlobalConsts.LEVEL_2) {
//                    ServProductQuery query = new ServProductQuery();
//                    query.setCategIds(arrayIds);
//                    query.setStatus(GlobalConsts.YES);
//                    query.setShowType(showType);
//                    List<ServProduct> servProducts = servProductService.listByQuery(query);
//                    if (!CollectionUtils.isEmpty(servProducts)) {
//                        return ResponseDTO.fail("服务分类+二级产品分类下的产品需全部下架");
//                    }
//                } else if (baseCategory.getLevel() == GlobalConsts.LEVEL_1) {
//                    BaseCategoryQuery query = new BaseCategoryQuery();
//                    query.setParentIds(arrayIds);
//                    query.setStatus(GlobalConsts.YES);
//                    query.setShowType(showType);
//                    List<BaseCategory> baseCategories = baseCategoryService.listByQuery(query);
//                    if (!CollectionUtils.isEmpty(baseCategories)) {
//                        return ResponseDTO.fail("一级产品分类的下级产品分类需全部停用");
//                    }
//                }
//            } else if (Objects.equals(GlobalConsts.YES, status)) {
//                if (baseCategory.getLevel() == GlobalConsts.LEVEL_2) {
//                    Integer categOneId = baseCategory.getParentId();
//                    BaseCategory categoryOne = baseCategoryService.findByKey(categOneId);
//                    if (categoryOne != null && Objects.equals(GlobalConsts.NO, categoryOne.getStatus())) {
//                        return ResponseDTO.fail("二级产品分类对应的一级产品分类需启用");
//                    }
//                }
//            }
//        }
//
//        return ResponseDTO.success(StatusConsts.STATUS_SUCCESS,GlobalConsts.SUCCESS_MSG);
//    }
//}
